<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Document</title>
    <link rel="stylesheet" href="../../css/api.css">
    <link rel="stylesheet" href="../../css/news.css">
    <link rel="stylesheet" href="../../css/login.css">
    <style>
        .login-bg {
            padding: 10px 0;
            width: 100vw;
        }
    </style>
</head>

<body>
    <div class="login-bg" id="view" v-cloak>
        <div class="wrap">
            <ul class="input-wrap w-bg">
                <li class="li phone new-hide">
                    <span class="name">{{_i18n('登录账号')}}</span>
                    <input type="text" :placeholder="_i18n('请输入手机号')">
                </li>
                <li class="li code">
                    <span class="name">{{_i18n('验证码')}}</span>
                    <input type="number" :placeholder="_i18n('请输入验证码')">
                    <span class="new-theme-color forget get-code" data-status=0 onclick="getCode(1)">{{_i18n('获取验证码')}}</span>
                </li>
            </ul>
            <div class="flex-c" style="margin-top: 50px;">
                <button class="new-tbtn" tapmode onclick="submit()">{{_i18n('下一步')}}</button>
            </div>
        </div>
    </div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/jquery.js"></script>
<script src="../../script/ffkj.js"></script>
<script src="../../script/keyboard.js"></script>
<script src="../../script/code.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/tent/im.js"></script>
<script src="../../script/tent/tencentCloudChat.js"></script>
<script>
    var view = new Vue({
        el: '#view',
        data: {
            ios: 1, // 1上架 0非上架
        }
    })
    apiready = function() {
        view.ios = $api.getStorage('shang');
        var info = api.pageParam['info'];
        if (info.phone) {
            $('.phone input').val(info.phone);
            getCode(1);
        } else {
            $('.phone').removeClass('new-hide');
        }
    }

    // 登录
    function submit() {
        var phone = $.trim($('.phone input').val());
        var code = $.trim($('.code input').val());
        if (!phone) {
            _msg('手机号未填写');
            return;
        }
        if (!checkMobile(phone)) {
            _msg('请输入正确的手机号');
            return;
        }
        if (!code) {
            _msg('请输入验证码');
            return;
        }
        _loading();
        _ajax('api/login/codeLogin', function(ret, err) {
            _loadingClose();
            if (ret && ret.code == 200) {
                
				initStorage(ret.result.id)
				userLogin(ret.result.id,ret.result.tencentId,function(){
					_msg('登录成功');
					$api.setStorage('userid', ret.result.id);
					$api.setStorage('sex', ret.result.sex);
					$api.setStorage('userSign', ret.result.tencentId);
					loginToUpdate(ret.result.id)
					_home();
				})
                
            } else if (ret && ret.code == 300) {
                var info = api.pageParam['info'];
                info.phone = phone;
                info.code = code;
                _url({
                    info: info
                }, 'frame0/she_zhi_ji_ben_zi_liao_frame');
            } else {
                _msg(ret.msg);
            }
        }, {
            phone: phone,
            code: code,
            device_id: api.deviceId
        })
    }
</script>

</html>